#include <iostream>

// 抽象产品
class Car
{
public:
    virtual void show() = 0;
};


// 具体产品
// 宝马
class BMW : public Car
{
public:
    BMW(int a) {}
    void show()
    {
        std::cout << "一辆宝马\n";
    }
};

// 奔驰
class Benz : public Car
{
public:
    Benz(double b) {}
    void show()
    {
        std::cout << "一辆奔驰\n";
    }
};

// 奥迪
class Audi : public Car
{
public:
    Audi(char c) {}
    void show()
    {
        std::cout << "一辆奥迪\n";
    }
};

// 工厂类
class Factory
{
public:
    virtual Car *Create() = 0;
};

// 宝马工厂
class BMWFactory : public Factory
{
public:
    Car *Create()
    {
        return new BMW(1);
    }
};

// 奔驰工厂
class BENZFactory : public Factory
{
public:
    Car *Create()
    {
        return new Benz(3.14);
    }
};

// 奥迪工厂
class AUDIFactory : public Factory
{
public:
    Car *Create()
    {
        return new Audi('c');
    }
};

int main()
{
    Factory *f = new BMWFactory;
    Car *c = f->Create();
    c->show();

    return 0;
}